package com.hn.service;

import com.hn.mapper.CnUserMapper;
import com.hn.model.CnUser;
import com.hn.util.IDGenerator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
/**
 * Created by s.
 */
@RestController
public class RestCnUserService {

     @Autowired
     private CnUserMapper cnUserMapper;

     @RequestMapping(value = "/getCnUserById",method = RequestMethod.POST)
     public CnUser getCnUserById(@RequestParam("id") String id)throws Exception{
         CnUser c = cnUserMapper.getCnUserById(id);
         c.setId(IDGenerator.uuid());
         addCnUser(c);
        return c;
     }

     @RequestMapping(value = "/getCnUserListByMap",method = RequestMethod.POST)
     public List<CnUser> getCnUserListByMap(@RequestParam Map<String,Object> param)throws Exception{
        return cnUserMapper.getCnUserListByMap(param);
     }

     @RequestMapping(value = "/getCnUserCountByMap",method = RequestMethod.POST)
     public Integer getCnUserCountByMap(@RequestParam Map<String,Object> param)throws Exception{
        return cnUserMapper.getCnUserCountByMap(param);
     }

     @RequestMapping(value = "/addCnUser",method = RequestMethod.POST ,produces = "application/json; charset=UTF-8")
     public Integer addCnUser(@RequestBody CnUser cnUser)throws Exception{
        return cnUserMapper.insertCnUser(cnUser);
     }

     @RequestMapping(value = "/qdtxModifyCnUser",method = RequestMethod.POST)
     public Integer qdtxModifyCnUser(@RequestBody CnUser cnUser)throws Exception{
        return cnUserMapper.updateCnUser(cnUser);
     }
}
